reward = 30000
salary = 5000

reward -= salary

sale = 0
for i in range(0,3):
    rate = 8 + i*2
    sale_temp = 5000 + 5000*i
    if reward > sale_temp*rate:
        sale += sale_temp
        reward = reward - sale_temp*rate
    else:
        sale += reward / rate

print(sale)


